/*  KDevelop 4.3.1
 *  BYTESE2.cxx
 *
 * 	Author : Pallab
 * 	Created on: 4:16:37 PM - 2013:1:18
 * 	"I have not failed, I have just found 10000 ways that won't work."
 */
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <numeric>
#include <stack>
#include <functional>
#include <bitset>
#include <iomanip>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;


#define foR(i,frm,upto) for( int i=(frm),_i=(upto);(i) < (_i) ; ++i )
#define foD(i,frm,upto) for( int i=(frm),_i=(upto);(i) >= (_i) ; --i )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )
#define line puts("")

inline void wait ( double seconds ) {
    double endtime = clock() + ( seconds * CLOCKS_PER_SEC );
    while ( clock() < endtime ) {
        ;
    }
}
template<class T>
    inline T fastIn() {
    register char c=0;
    register T a=0;
    bool neg=false;
    while ( c<33 ) c=getchar();
    while ( c>33 ) {
        if ( c=='-' ) {
            neg=true;
        } else {
            a= ( a*10 ) + ( c-'0' );
        }
        c=getchar();
    }
    return neg?-a:a;
}
// #include "MyHash.h"
// #include "BIT.h"
//********************************
//REMEMBER 1[ONE] BASED INDEXING//
//********************************
template<class T>
    class BIT {
        private:
        int MAX_BIT;
        T *Tree;
        public:
        BIT ( int size ) {
            this->MAX_BIT = size;
            Tree = new T[this->MAX_BIT+1];
            fill ( Tree,Tree+size+1,0 );
        }
        ~BIT() {
            delete[] Tree;
        }
        inline void Update ( int idx,T delta ) {
            if ( idx<=0 ) return ;

            while ( idx<MAX_BIT ) {
                Tree[idx]+=delta;
                idx+= ( idx & -idx );
            }
        }
        inline T Query ( int idx ) {
            if ( idx<=0 ) return 0;

            T ret=0;
            while ( idx>0 ) {
                ret+=Tree[idx];
                idx-= ( idx & -idx );
            }
            return ret;
        }
    };
// kate: indent-mode cstyle; indent-width 4; replace-tabs on; 

template<class S>
    class MyHash {
        private:
        int MAX_HAS_LEN;
        map<S,int> mp;
        S *points;
        int nPoints;
        int ID;
        public:
        MyHash ( int size ) {
            this->MAX_HAS_LEN=size;
            points = new S[size];
            ID=1;
            mp.clear();
            nPoints=0;
        }
        ~MyHash() {
            delete[] points;
        }
        inline void Push ( S point ) {
            points[nPoints]=point;
            ++nPoints;
        }
        inline void Encode() {
            sort ( points,points+nPoints,less<S>() );
            S prv;
            bool prothom=true;
            for ( int i=0; i<nPoints; ++i ) {
                if ( prothom ) {
                    prothom=false;
                    prv=points[i];
                    mp[ points[i] ]=ID;
                    ++ID;
                } else {
                    if ( prv!=points[i] ) {
                        prv=points[i];

                        mp[ points[i] ]=ID;
                        ++ID;
                    }
                }
            }
        }
        inline int GetId ( S point ) {
            return mp[point];
        }
        inline int PointCounts() {
            return ID;
        }

    };
// kate: indent-mode cstyle; indent-width 4; replace-tabs on; 



int peopleCount;
multiset< pair<int,int> > points;
inline void read() {
    points.clear();
    peopleCount=fastIn<int>();
    int s,t;
    foR ( i,0,peopleCount ) {
        s=fastIn<int>(),t=fastIn<int>();
        points.insert ( mk ( s,t ) );
    }
}
pair<int,int> pp[105];
inline void proc() {

    peopleCount=0;
    set<int> seen;
    while ( points.empty() ==false ) {
        int s=points.begin()->first;
        int t=points.begin()->second;
        points.erase ( points.begin() );

        while ( seen.count ( s ) >0 ) ++s;
        while ( seen.count ( t ) >0 ) ++t;
        if ( s<t ) {
            seen.insert ( s );
            seen.insert ( t );
            pp[peopleCount++]=mk ( s,t );
        }
    }
    MyHash<int> myhash ( ( peopleCount<<1 ) +10 );
    foR ( i,0,peopleCount ) {
        myhash.Push ( pp[i].first );
        myhash.Push ( pp[i].second );
    }
    myhash.Encode();
    BIT<int> tree ( myhash.PointCounts() +5 );

    foR ( i,0,peopleCount ) {
        int s=  myhash.GetId ( pp[i].first ),t=myhash.GetId ( pp[i].second );
        tree.Update ( s,1 );
        tree.Update ( t+1,-1 );
    }
    int bst=0;
    foR ( i,0, myhash.PointCounts() +1 ) {
        bst=max ( bst, tree.Query ( i ) );
    }
    cout<<bst<<"\n";
}
int main() {
    int kase = 1;
#if defined( xerxes_pc )
    freopen ( "in1", "r", stdin );
    kase = 1;
#endif
    kase=fastIn<int>();
    for ( int i=1; i<=kase; ++i ) {
        read();
        proc();
    }
    return 0;
}

// kate: indent-mode cstyle; indent-width 4; replace-tabs on; 


